//
// Created by xili on 2024/8/30 21:26.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int partitionArray(vector<int> &nums, int k) {
        sort(nums.begin(), nums.end());
        int ans = 1;
        int n = nums.size();
        int min = nums[0];
        for (int i = 1; i < n; i++) {
            if (nums[i] - min > k) {
                ans++;
                min = nums[i];
            }
        }
        return ans;
    }
};